<?php

/**
 * 前台 新闻 模块 Controller
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: xing7878@gmail.com $  <zwttmac@qq.com>
 * $Id: show.php 61 2011-08-03 02:24:04Z xing7878@gmail.com $
 * http://www.t-mac.org；
 */
class showAction extends Action
{

    private $tmp_model;
    private $news_model;
    private $show_model;
    private $article_model;
    private $index_model;

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('show');
        $this->news_model = Tmac::model('news');
        $this->index_model = Tmac::model('index');
        $this->article_model = Tmac::model('article', 'admin');

        $this->M('index')->getCommon();
    }

    public function index()
    {
        $name = $this->H($this->getParam('name'));
        $name = empty($name) ? 'aboutus' : $name;
        $catinfo = $this->tmp_model->getCategoryInfo($name);

        $cid = intval($this->getParam('id'));
        $cat_info_byid = $this->tmp_model->getCategoryInfoById($cid);                
        $cat_list = $this->news_model->getCategoryList($catinfo['cat_id']);
        $cid = empty($cid) ? $cat_list[0]['cat_id'] : $cid;

        $info = $this->tmp_model->getCategoryInfoById($cid);
        $nicename = $this->index_model->getToptypeNmae($name);
        
        $this->assign('nicename', $nicename);
        $this->assign('cid', $cid);
        $this->assign('catinfo', $catinfo);
        $this->assign('cat_info_byid', $cat_info_byid);
        $this->assign('info', $info);
        $this->assign('name', $name);
        $this->assign('cat_list', $cat_list);
        $this->V('show');
    }

}